package com.dllo.lanou.cookapp.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.dllo.lanou.cookapp.R;
import com.dllo.lanou.cookapp.entity.BookDes;
import com.dllo.lanou.cookapp.entity.BookList;
import com.dllo.lanou.cookapp.entity.BookListEntity;
import com.dllo.lanou.cookapp.view.MyListView;
import com.dllo.lanou.cookapp.volly.GetVolleyImage;
import com.dllo.lanou.cookapp.volly.VolleySingleton;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;

public class BookDescritionActivity extends AppCompatActivity implements View.OnClickListener {


    private BookListEntity book;
    private  int id;

    @Bind(R.id.book_des_author)
    TextView author;
    @Bind(R.id.book_des_name)
    TextView name;

    @Bind(R.id.book_des_img)
    ImageView book_img;
    @Bind(R.id.book_des_summary)
    TextView summary;
    @Bind(R.id.book_des_into)
    Button book_des_into;
    @Bind(R.id.book_des_back)
    ImageView book_des_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_descrition);
        ButterKnife.bind(this);
        Intent intent  = getIntent();
        book = (BookListEntity) intent.getSerializableExtra("book");
        id = book.getId();
        Log.i("书籍的的数据详情id",id+"");
        name.setText(book.getName());
        author.setText(book.getAuthor());
        summary.setText(book.getSummary());
        GetVolleyImage.getNetWorkImg("http://tnfs.tngou.net/image"+book.getImg(),book_img);
       // requestData();
        book_des_into.setOnClickListener(this);
        book_des_back.setOnClickListener(this);
    }




    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.book_des_into:
                Intent intent = new Intent(this,ReadBookActivty.class);
                intent.putExtra("id",id);
                startActivity(intent);
            break;
            case R.id.book_des_back:

                finish();
                break;

        }
    }
}
